import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by Administrator on 2017/9/25.
 */
@WebServlet(name = "HttpServletOne",urlPatterns = "/lai")
public class HttpServletOne extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // resp.setCharacterEncoding("utf-8");
        // resp.setHeader("Content-Type","text/html;charset = utf-8");
        resp.setContentType("text/html;charset=utf-8");
        //设置3秒后自动跳转
        resp.setHeader("refresh","3;");
        resp.setHeader("refresh","3");
        //重定向
        //resp.sendRedirect("http://www.baidu.com");
        resp.sendRedirect("/untitled/login.jsp");
        PrintWriter out = resp.getWriter();
        out.write("winner winner chicken dinner \n");
        out.write("大吉大利 今晚吃鸡");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }
}
